function mergeTwoLists(l1, l2) {
  let dummyHead = new ListNode()
  let p = dummyHead
  let a = l1, b = l2
  while (a && b) {
    if (a.val < b.val) {
      p.next = a
      a = a.next
    } else {
      p.next = b
      b = b.next
    }
    p = p.next
  }
  if (a !== null) {
    p.next = a
  }
  if (b !== null) {
    p.next = b
  }
  return dummyHead.next
}